<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"  %>
<%@ taglib uri="/WEB-INF/struts-template.tld" prefix="template" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<style type="text/css">
body, a, table, div, span, td, th, input, select{font:9pt;font-family: Verdana, Arial, Helvetica, sans-serif;}
body {padding:5px}
</style>

<script language="JavaScript" src="dialog.js"></script>

<script language="JavaScript">
var sAction = "INSERT";
var sTitle = "<bean:message bundle='webEditor'  key='webEditor.Insert' />";

var oControl;
var oSeletion;
var sRangeType;

var sFromUrl = "";
var sAlt = "";
var sBorder = "0";
var sBorderColor = "#000000";
var sFilter = "";
var sAlign = "";
var sWidth = "";
var sHeight = "";
var sVSpace = "";
var sHSpace = "";

var sCheckFlag = "file";

oSelection = dialogArguments.eWebEditor.document.selection.createRange();
sRangeType = dialogArguments.eWebEditor.document.selection.type;

if (sRangeType == "Control") {
	if (oSelection.item(0).tagName == "IMG"){
		sAction = "MODI";
		sTitle = "<bean:message bundle='webEditor'  key='webEditor.Modify' />";
		sCheckFlag = "url";
		oControl = oSelection.item(0);
		sFromUrl = oControl.src;
		sAlt = oControl.alt;
		sBorder = oControl.border;
		sBorderColor = oControl.style.borderColor;
		sFilter = oControl.style.filter;
		sAlign = oControl.align;
		sWidth = oControl.width;
		sHeight = oControl.height;
		sVSpace = oControl.vspace;
		sHSpace = oControl.hspace;
	}
}


document.write("<title><bean:message bundle='webEditor'  key='webEditor.InsertImage.Title' />(" + sTitle + ")</title>");



function InitDocument(){
	SearchSelectValue(d_filter, sFilter);
	SearchSelectValue(d_align, sAlign.toLowerCase());

	d_fromurl.value = sFromUrl;
	d_alt.value = sAlt;
	d_border.value = sBorder;
	d_bordercolor.value = sBorderColor;
	s_bordercolor.style.backgroundColor = sBorderColor;
	d_width.value = sWidth;
	d_height.value = sHeight;
	d_vspace.value = sVSpace;
	d_hspace.value = sHSpace;
}



/*function RadioClick(what){
	if (what=="url"){
		d_checkfromfile.checked=false;
		d_fromurl.disabled=false;
		//d_checkfromurl.checked=true;
		d_file.myform.uploadfile.disabled=true;
	}else{
		d_checkfromurl.checked=false;
		d_file.myform.uploadfile.disabled=false;
		d_checkfromfile.checked=true;
		d_fromurl.disabled=true;
	}
}
*/


function UploadSaved(sFileName){
	d_fromurl.value=GetHttpUrl(config.StyleUploadDir+"/"+sFileName);
	ReturnValue();
}


function ReturnValue(){
	sFromUrl = d_fromurl.value;
	sAlt = d_alt.value;
	sBorder = d_border.value;
	sBorderColor = d_bordercolor.value;
	sFilter = d_filter.value;
	sAlign = d_align.value;
	sWidth = d_width.value;
	sHeight = d_height.value;
	sVSpace = d_vspace.value;
	sHSpace = d_hspace.value;

	if (sAction == "MODI") {
		oControl.src = sFromUrl;
		oControl.alt = sAlt;
		oControl.border = sBorder;
		oControl.style.borderColor = sBorderColor;
		oControl.style.filter = sFilter;
		oControl.align = sAlign;
		oControl.width = sWidth;
		oControl.height = sHeight;
		oControl.vspace = sVSpace;
		oControl.hspace = sHSpace;
	}else{
		var sHTML = '<img src="'+sFromUrl+'" alt="'+sAlt+'" border="'+sBorder+'" style="filter:'+sFilter+';border-color:'+sBorderColor+'" align="'+sAlign+'"';
		if (sWidth!=""){
			sHTML=sHTML+' width="'+sWidth+'"';
		}
		if (sHeight!=""){
			sHTML=sHTML+' height="'+sHeight+'"';
		}
		sHTML = sHTML+' vspace="'+sVSpace+'" hspace="'+sHSpace+'">';
		dialogArguments.insertHTML(sHTML);
	}

	window.returnValue = null;
	window.close();
}


function ok(){

	d_border.value = ToInt(d_border.value);
	d_width.value = ToInt(d_width.value);
	d_height.value = ToInt(d_height.value);
	d_vspace.value = ToInt(d_vspace.value);
	d_hspace.value = ToInt(d_hspace.value);

	if (!IsColor(d_bordercolor.value)){
		BaseAlert(d_bordercolor,"<bean:message bundle='webEditor'  key='webEditor.Color' />");
		return false;
	}
 	ReturnValue();
}


function DisableItems(){
 	d_fromurl.disabled=true;
	d_alt.disabled=true;
	d_border.disabled=true;
	d_bordercolor.disabled=true;
	d_filter.disabled=true;
	d_align.disabled=true;
	d_width.disabled=true;
	d_height.disabled=true;
	d_vspace.disabled=true;
	d_hspace.disabled=true;
	Ok.disabled=true;
}


function AbleItems(){
 	d_fromurl.disabled=false;
	d_alt.disabled=false;
	d_border.disabled=false;
	d_bordercolor.disabled=false;
	d_filter.disabled=false;
	d_align.disabled=false;
	d_width.disabled=false;
	d_height.disabled=false;
	d_vspace.disabled=false;
	d_hspace.disabled=false;
	Ok.disabled=false;
}
 function UploadImport(){
   var dEL = document.all("d_fromurl");
    var url = "<html:rewrite page='/protected/resmgr/initDirectory.do' />?CallFromTemplateDesign=true ";
	var arr = showModalDialog(url,window,"dialogWidth:750px;dialogHeight:600px;help:no;scroll:yes;status:no");
	if (arr) {
		dEL.value=arr;
	}
}
</script>

<BODY bgColor=menu onload="InitDocument()">

<table border=0 cellpadding=0 cellspacing=0 align=center>
<tr>
	<td>
	<fieldset>
	<legend><bean:message bundle='webEditor'  key='webEditor.Image.Source' /></legend>
	<table border=0 cellpadding=0 cellspacing=0>
	<tr><td colspan=9 height=5></td></tr>

	<tr>
		<td width=7></td>
 		<td colspan=5><input type=text id="d_fromurl" style="width:220px" size=25 value="" ></td>
		<td width=5></td>
		<td width=7><input type=button value="<bean:message bundle='webEditor'  key='webEditor.InsertImage.Upload' />" onclick="UploadImport()"></td>
		<td width=5></td>
		<td width=5><input type=submit value="<bean:message bundle='webEditor'  key='webEditor.InsertImage.Import' />" onclick="UploadImport()"></td>
	</tr>
	<tr><td colspan=9 height=5></td></tr>
 	</table>
	</fieldset>
	</td>
</tr>
<tr><td height=5></td></tr>
<tr>
	<td>
	<fieldset>
	<legend><bean:message bundle='webEditor'  key='webEditor.Image.Effect' /></legend>
	<table border=0 cellpadding=0 cellspacing=0>
	<tr><td colspan=9 height=5></td></tr>
	<tr>
		<td width=7></td>
		<td><bean:message bundle='webEditor'  key='webEditor.InsertImage.Explain' /></td>
		<td width=5></td>
		<td colspan=5><input type=text id=d_alt size=38 value="" style="width:243px"></td>
		<td width=7></td>
	</tr>
	<tr><td colspan=9 height=5></td></tr>
	<tr>
		<td width=7></td>
		<td noWrap><bean:message bundle='webEditor'  key='webEditor.RimThickness' /></td>
		<td width=5></td>
		<td><input type=text id=d_border size=10 value="" ONKEYPRESS="event.returnValue=IsDigit();"></td>
		<td width=40></td>
		<td noWrap><bean:message bundle='webEditor'  key='webEditor.RimColor' /></td>
		<td width=5></td>
		<td><table border=0 cellpadding=0 cellspacing=0><tr><td><input type=text id=d_bordercolor size=7 value=""></td><td><img border=0 src="../sysimage/rect.gif" width=18 style="cursor:hand" id=s_bordercolor onclick="SelectColor('bordercolor')"></td></tr></table></td>
		<td width=7></td>
	</tr>
	<tr><td colspan=9 height=5></td></tr>
	<tr>
		<td width=7></td>
		<td><bean:message bundle='webEditor'  key='webEditor.InsertImage.SpecialColor' /></td>
		<td width=5></td>
		<td>
			<select id=d_filter style="width:72px" size=1>
			<option value='' selected><bean:message bundle='webEditor'  key='webEditor.InsertImage.SpecialColor.option.1' /></option>
			<option value='Alpha(Opacity=50)'><bean:message bundle='webEditor'  key='webEditor.InsertImage.SpecialColor.option.2' /></option>
			<option value='Alpha(Opacity=0, FinishOpacity=100, Style=1, StartX=0, StartY=0, FinishX=100, FinishY=140)'><bean:message bundle='webEditor'  key='webEditor.InsertImage.SpecialColor.option.3' /></option>
			<option value='Alpha(Opacity=10, FinishOpacity=100, Style=2, StartX=30, StartY=30, FinishX=200, FinishY=200)'><bean:message bundle='webEditor'  key='webEditor.InsertImage.SpecialColor.option.4' /></option>
			<option value='blur(add=1,direction=14,strength=15)'><bean:message bundle='webEditor'  key='webEditor.InsertImage.SpecialColor.option.5' /></option>
			<option value='blur(add=true,direction=45,strength=30)'><bean:message bundle='webEditor'  key='webEditor.InsertImage.SpecialColor.option.6' /></option>
			<option value='Wave(Add=0, Freq=60, LightStrength=1, Phase=0, Strength=3)'><bean:message bundle='webEditor'  key='webEditor.InsertImage.SpecialColor.option.7' /></option>
			<option value='gray'><bean:message bundle='webEditor'  key='webEditor.InsertImage.SpecialColor.option.8' /></option>
			<option value='Chroma(Color=#FFFFFF)'><bean:message bundle='webEditor'  key='webEditor.InsertImage.SpecialColor.option.9' /></option>
			<option value='DropShadow(Color=#999999, OffX=7, OffY=4, Positive=1)'><bean:message bundle='webEditor'  key='webEditor.InsertImage.SpecialColor.option.10' /></option>
			<option value='Shadow(Color=#999999, Direction=45)'><bean:message bundle='webEditor'  key='webEditor.InsertImage.SpecialColor.option.11' /></option>
			<option value='Glow(Color=#ff9900, Strength=5)'><bean:message bundle='webEditor'  key='webEditor.InsertImage.SpecialColor.option.12' /></option>
			<option value='flipv'><bean:message bundle='webEditor'  key='webEditor.InsertImage.SpecialColor.option.13' /></option>
			<option value='fliph'><bean:message bundle='webEditor'  key='webEditor.InsertImage.SpecialColor.option.14' /></option>
			<option value='grays'><bean:message bundle='webEditor'  key='webEditor.InsertImage.SpecialColor.option.15' /></option>
			<option value='xray'><bean:message bundle='webEditor'  key='webEditor.InsertImage.SpecialColor.option.16' /></option>
			<option value='invert'><bean:message bundle='webEditor'  key='webEditor.InsertImage.SpecialColor.option.17' /></option>
            </select>
		</td>
		<td width=40></td>
		<td><bean:message bundle='webEditor'  key="webEditor.HorAlign" /></td>
		<td width=5></td>
		<td>
			<select id=d_align size=1 style="width:72px">
			<option value='' selected><bean:message bundle='webEditor'  key='webEditor.HorAlign.option.1' /></option>
			<option value='left'><bean:message bundle='webEditor'  key='webEditor.HorAlign.option.2' /></option>
			<option value='right'><bean:message bundle='webEditor'  key='webEditor.HorAlign.option.3' /></option>
			<option value='top'><bean:message bundle='webEditor'  key='webEditor.HorAlign.option.4' /></option>
			<option value='middle'><bean:message bundle='webEditor'  key='webEditor.HorAlign.option.5' /></option>
			<option value='bottom'><bean:message bundle='webEditor'  key='webEditor.HorAlign.option.6' /></option>
			<option value='absmiddle'><bean:message bundle='webEditor'  key='webEditor.HorAlign.option.7' /></option>
			<option value='absbottom'><bean:message bundle='webEditor'  key='webEditor.HorAlign.option.8' /></option>
			<option value='baseline'><bean:message bundle='webEditor'  key='webEditor.HorAlign.option.9' /></option>
			<option value='texttop'><bean:message bundle='webEditor'  key='webEditor.HorAlign.option.10' /></option>
			</select>
		</td>
		<td width=7></td>
	</tr>
	<tr><td colspan=9 height=5></td></tr>
	<tr>
		<td width=7></td>
		<td><bean:message bundle='webEditor'  key="webEditor.InsertImage.Width" /></td>
		<td width=5></td>
		<td><input type=text id=d_width size=10 value="" ONKEYPRESS="event.returnValue=IsDigit();" maxlength=4></td>
		<td width=40></td>
		<td><bean:message bundle='webEditor'  key="webEditor.InsertImage.Height" /></td>
		<td width=5></td>
		<td><input type=text id=d_height size=10 value="" ONKEYPRESS="event.returnValue=IsDigit();" maxlength=4></td>
		<td width=7></td>
	</tr>
	<tr><td colspan=9 height=5></td></tr>
	<tr>
		<td width=7></td>
		<td><bean:message bundle='webEditor'  key="webEditor.InsertImage.D_vspace" /></td>
		<td width=5></td>
		<td><input type=text id=d_vspace size=10 value="" ONKEYPRESS="event.returnValue=IsDigit();" maxlength=2></td>
		<td width=40></td>
		<td><bean:message bundle='webEditor'  key="webEditor.InsertImage.D_hspace" /></td>
		<td width=5></td>
		<td><input type=text id=d_hspace size=10 value="" ONKEYPRESS="event.returnValue=IsDigit();" maxlength=2></td>
		<td width=7></td>
	</tr>
	<tr><td colspan=9 height=5></td></tr>
	</table>
	</fieldset>
	</td>
</tr>
<tr><td height=5></td></tr>
<tr><td align=right><input type=submit value="<bean:message bundle='webEditor'  key='webEditor.Confirm' />" id=Ok onclick="ok()">&nbsp;&nbsp;<input type=button value="<bean:message bundle='webEditor'  key='webEditor.Cancel' />" onclick="window.close();"></td></tr>
</table>
</body>
</html>
